{template 'common/header'}
<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('reward')}">获奖列表</a></li>
</ul>
{if $op == 'display'}
<style>
th{
	text-align: center !important;
}
td{
	text-align: center !important;
	white-space: normal !important;
	word-break: break-all !important;
}
</style>
<form action="" method="get" class="form-horizontal" role="form">
<div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="junsion_challeng" />
                <input type="hidden" name="do" value="reward" />
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">会员信息</label>
                    <div class="col-xs-12 col-sm-2 col-lg-2">
                        <input class="form-control" name="m_kwd" type="text" value="{$_GPC['m_kwd']}" placeholder="请输入会员昵称">
                    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">礼品信息</label>
                    <div class="col-xs-12 col-sm-2 col-lg-2">
                        <input class="form-control" name="g_kwd" type="text" value="{$_GPC['g_kwd']}" placeholder="请输入礼品名称">
                    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
				    <div class="col-xs-12 col-sm-2 col-lg-2">
				        <select class="form-control" style="margin-right:15px;" name="status">
				            <option value="">全部</option>
				            <option value="0" {if empty($_GPC['status']) && $_GPC['status']!=''} selected="selected"{/if}>待支付</option>
				            <option value="1" {if 1 == $_GPC['status']} selected="selected"{/if}>待发货</option>
				            <option value="2" {if 2 == $_GPC['status']} selected="selected"{/if}>已发货</option>
				        </select>
				    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">游戏类型</label>
				    <div class="col-xs-12 col-sm-2 col-lg-2">
				        <select class="form-control" style="margin-right:15px;" name="gtype">
				            <option value="">全部</option>
				            <option value="0" {if empty($_GPC['gtype']) && $_GPC['gtype']!=''} selected="selected"{/if}>挑战智力</option>
				            <option value="1" {if 1 == $_GPC['gtype']} selected="selected"{/if}>挑战注意力</option>
				            <option value="2" {if 2 == $_GPC['gtype']} selected="selected"{/if}>挑战知识</option>
				            <option value="3" {if 3 == $_GPC['gtype']} selected="selected"{/if}>加减大师</option>
				            <option value="4" {if 4 == $_GPC['gtype']} selected="selected"{/if}>成语填填看</option>
				            <option value="5" {if 5 == $_GPC['gtype']} selected="selected"{/if}>看图填词</option>
				            <option value="6" {if 6 == $_GPC['gtype']} selected="selected"{/if}>猜歌达人</option>
				            <option value="7" {if 7 == $_GPC['gtype']} selected="selected"{/if}>挑战眼力</option>
				            <option value="8" {if 8 == $_GPC['gtype']} selected="selected"{/if}>多彩青蛙</option>
				            <option value="9" {if 9 == $_GPC['gtype']} selected="selected"{/if}>猴子过桥</option>
				        </select>
				    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">支付方式</label>
				    <div class="col-xs-12 col-sm-2 col-lg-2">
				        <select class="form-control" style="margin-right:15px;" name="paytype">
				            <option value="">全部</option>
				            <option value="0" {if empty($_GPC['paytype']) && $_GPC['paytype']!=''} selected="selected"{/if}>余额支付</option>
				            <option value="1" {if 1 == $_GPC['paytype']} selected="selected"{/if}>微信支付</option>
				        </select>
				    </div>
				    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">时间</label>
                    <div class="col-xs-12 col-sm-3 col-lg-3">
                        {php echo tpl_form_field_daterange('dateline',array('start'=>date('Y-m-d H:i',$start),'end'=>date('Y-m-d H:i',$end)),true);}
                    </div> 
                    <div class=" col-xs-12 col-sm-1 col-lg-1">
                        <button class="btn btn-default" ><i class="fa fa-search"></i> 搜索</button>
                        <!-- <button class="btn btn-primary" name='export' value='1' >导出</button> -->
                   	</div>
                </div>
        </div>
    </div>
</form>

<div class="panel panel-default">
<div class="panel-heading">订单总数：{$total1}；订单总金额：￥{$money1}；筛选总数：{$total}；筛选金额：￥{$money}；</div>
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
            	<th>奖励单号<br/>游戏</th>
            	<th>会员信息</th>
                <th>礼品信息</th>
                <th>支付方式</th>
                <th>状态</th>
                <th>联系信息</th>
                <th>备注</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="reward-list">
            {loop $list $item}
            <tr>
            	<td>
            	{$item['orderno']}<br/>
            	{if $item['type']==0}挑战智力{/if}
            	{if $item['type']==1}挑战注意力{/if}
            	{if $item['type']==2}挑战知识{/if}
            	{if $item['type']==3}加减大师{/if}
            	{if $item['type']==4}成语填填看{/if}
            	{if $item['type']==5}看图填词{/if}
            	{if $item['type']==6}猜歌达人{/if}
            	{if $item['type']==7}挑战眼力{/if}
            	{if $item['type']==8}多彩青蛙{/if}
            	{if $item['type']==9}猴子过桥{/if}
            	</td>
            	<td><img src="{$mems[$item['mid']]['avatar']}" style="width:60px;"><br/>{$mems[$item['mid']]['nickname']}</td>
            	<td><img src="{php echo toimage($gifts[$item['gid']]['logo'])}" style="width:60px;"><br/>{$gifts[$item['gid']]['title']}</td>
               	<td>
               		{if $item['paytype']==1}<label class="label label-success">微信支付</label>{/if}
               	</td>
               	<td>
               		{if $item['status'] == 0}
	               <label class="label label-default">待支付</label>
	               	{if $item['price']>0}
		            <br>{$item['price']} 元
		            {/if}
	               {else}
		               {if $item['status'] == 1}
		               <label class="label label-warning">待发货</label>
		               	{elseif $item['status'] == 2}
		               <label class="label label-success">已发货</label>
		               {/if}
		               {if $item['price']>0}
		               <br>{$item['price']} 元
		               <br/>{$item['transid']}
		               {/if}
	               {/if}
              	</td>
              	<td>{$item['uname']}<br/>{$item['mobile']}{if !empty($item['addr'])}<br/>{$item['addr']}{/if}</td>
              	<td>{$item['remark']}</td>
               	<td>{php echo date('Y-m-d H:i',$item['createtime']);}</td>
               <td>
                   {if $item['status'] == 1}
                   <a class="btn btn-primary btn-sm" onclick="goSend({$item['id']});" href="JavaScript:;">发货</a>
                   {/if}
                   <a class="btn btn-danger btn-sm" onclick="return confirm('确认删除吗？');return false;" href="{php echo $this->createWebUrl('reward', array('op' => 'del', 'id' => $item['id']))}">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</div>
<style>
.check_bg{
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.5);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99;
    display: none;
}
.check_main{
	width: 40%;
    height: auto;
    background: #fff;
    position: fixed;
    top: 150px;
    left: 30%;
    border-radius: 5px;
}
.check_main>textarea{
	width: 80%;
    margin-left: 10%;
    margin-top: 0px;
    height: 100px;
    border-radius: 5px;
}
.check_main>button{
    display: block;
    margin-top: 10px;
    border: none;
    border-radius: 5px;
    height: 34px;
    width: 80%;
    margin-left: 10%;
    margin-bottom: 20px;
    background: #5bc0de;
    color: #fff;
}
.check_main .title{
	text-align: center;
    height: 50px;
    line-height: 50px;
    font-size: 18px;
    font-weight: bold;
}
.check_close{
	position: fixed;
    left: 68.5%;
    margin-top: 10px;
    font-size: 16px;
}
.control-label{
	text-align: right;
}
.form-group{
	height: 30px;
}
</style>
<div class="check_bg">
	<div class="check_main">
        <span class="check_close"
              onclick="$('#platformeran').val('');$('.platformearn').val(0);$('.infoearn').val(0);$('.check_bg').hide();$('#infolevel').html('');$('#itemlevel').html('');">X</span>
		<div class='title'>请选择发货礼品</div>
		<div class="panel panel-info">
	        <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 control-label">礼品</label>
                    <div class="col-xs-12 col-sm-8 col-lg-8">
                    	<select id="selGift" name="selGift" class="form-control">
                    		{loop $allgifts $g}
                    		<option value="{$g['id']}">{$g['title']}</option>
                    		{/loop}
                    	</select>
                    </div>
                </div>
				
	        </div>
        </div>
		<button id="check_btn" onclick="doSend(this);">提交</button>
	</div>
</div>
<script>
var rid = 0;
function goSend(id){
	rid = id;
	$('.check_bg').show();
}
function doSend(){
	if(!rid || rid==0){
		alert('奖品记录不存在');
		return false;
	}
	var gid = $('#selGift').val();
	if(!gid){
		alert('请选择发货礼品');
		return false;
	}
	$.ajax({
		url:"{php echo $this->createWebUrl('reward', array('op' => 'send'))}",
		type:'post',
		data:{id:rid,gid:gid},
		success:function(data){
			console.log(data);
			if(data == '1'){
				alert('操作成功');
				window.location.reload(); 
			}else{
				alert('操作失败');
			}
		}
	});
}
</script>
{/if}
